#include "Partner.h"

#include <QEvent>
#include <QHostAddress>

Partner::Partner(QWidget *parent, quint32 ip)
    : QLabel(parent)
    , m_ip(ip)
{
    this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    m_width = ((QWidget *)this->parent())->size().width();

    auto pixmap = QPixmap::fromImage(QImage(":/myImage/1.jpg").scaled(m_width - 10,  m_width - 10));
    this->setPixmap(pixmap);
    this->setFrameShape(QFrame::Box);

    this->setStyleSheet("border-width: 1px; border-style: solid; border-color:rgba(0, 0 , 255, 0.7)");
    this->setToolTip(QHostAddress(m_ip).toString());
}

void Partner::setPic(QImage img)
{
    this->setPixmap(QPixmap::fromImage(img.scaled(m_width - 10, m_width - 10)));
}


void Partner::mousePressEvent(QMouseEvent *ev)
{
    emit sendIp(m_ip);
}

